﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
//using System.Data.SqlServerCe;
using System.Data.SqlClient;

namespace BiSA
{

    class BAL
    {
        public int OneValue { get; set; }
        public int TwoValue { get; set; }
        public static bool SaveHeadings()
        {
            if (MessageBox.Show("Do you want to save column headings?", "BiSA", MessageBoxButtons.YesNo) == DialogResult.Yes)
                return true;
            else
                return false;
        }
        public static void CleanupDB()
        {
            SqlCommand cm = MKDataAccesser.CreateCommand("sp_CleanUpDB", CommandType.StoredProcedure);
            MKDataAccesser.ExecuteMyQuery(cm);
        }

        public static int GetOverlapCount(string UserDataDetailId, string TFId, string bpOverlap, string CentreDistance)
        {
            SqlCommand cm = MKDataAccesser.CreateCommand("sp_GetAllCommonOverlapCount", CommandType.StoredProcedure);
            cm.Parameters.Add(new SqlParameter("@UserDataDetailId", UserDataDetailId));
            cm.Parameters.Add(new SqlParameter("@TFId", TFId));
            cm.Parameters.Add(new SqlParameter("@bpOverlap", bpOverlap));
            cm.Parameters.Add(new SqlParameter("@CentreDistance", CentreDistance));
            SqlParameter param = new SqlParameter("@TotalCount", SqlDbType.VarChar, 50);
            param.Direction = ParameterDirection.Output;
            cm.Parameters.Add(param);
            MKDataAccesser.ExecuteMyQuery(cm);
            return Convert.ToInt16(cm.Parameters["@TotalCount"].Value.ToString());
        }
        public static int Get2KBOverlapCount(string KB1, string KB2, string bpOverlap, string CentreDistance)
        {
            SqlCommand cm = MKDataAccesser.CreateCommand("sp_Get2KBOverlapCount", CommandType.StoredProcedure);
            cm.Parameters.Add(new SqlParameter("@KB1", KB1));
            cm.Parameters.Add(new SqlParameter("@KB2", KB2));
            cm.Parameters.Add(new SqlParameter("@bpOverlap", bpOverlap));
            cm.Parameters.Add(new SqlParameter("@CentreDistance", CentreDistance));
            SqlParameter param = new SqlParameter("@TotalCount", SqlDbType.VarChar, 50);
            param.Direction = ParameterDirection.Output;
            cm.Parameters.Add(param);
            MKDataAccesser.ExecuteMyQuery(cm);
            return Convert.ToInt16(cm.Parameters["@TotalCount"].Value.ToString());
        }
        public static int GetAllCommonOverlap(string UserDataDetailId, string bpOverlap, string CentreDistance)
        {
            SqlCommand cm = MKDataAccesser.CreateCommand("sp_GetAllCommonOverlapSites", CommandType.StoredProcedure);
            cm.Parameters.Add(new SqlParameter("@UserDataDetailId", UserDataDetailId));
            cm.Parameters.Add(new SqlParameter("@bpOverlap", bpOverlap));
            cm.Parameters.Add(new SqlParameter("@CentreDistance", CentreDistance));
            SqlParameter param = new SqlParameter("@TotalMatched", SqlDbType.VarChar, 50);
            param.Direction = ParameterDirection.Output;
            cm.Parameters.Add(param);
            MKDataAccesser.ExecuteMyQuery(cm);
            return Convert.ToInt16(cm.Parameters["@TotalMatched"].Value.ToString());

        }

    }

}
